package com.packet.controller;

import com.packet.service.FinanceUploadService;
import com.packet.utils.AliOSSUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;

/**
 * @className:FinanceUploadController
 * @Author:wallet_packet Date:2023-12-10 18:03
 * @Describe:
 */
@Controller
public class FinanceUploadController {
    @Autowired
    AliOSSUtils aliOSSUtils;
    @Autowired
    FinanceUploadService financeUploadService;

    @PostMapping("/finance/uploadFile")
    @ResponseBody
    public String uploadFile(MultipartFile image) throws Exception {
        System.out.println(image);
        System.out.println(image.getOriginalFilename());
        String filename = aliOSSUtils.upload(image);
        System.out.println(filename);
        HashMap<String, Object> map = new HashMap<>();
        map.put("filename",filename);
        financeUploadService.insertFileName(map);
        return "ok";
    }
}
